package com.atguigu.admin.exception;

/**
 * @Author: LDeng
 * @Date: 2021-09-16 13:53
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * 处理整个web的controller异常
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler({ArithmeticException.class,NullPointerException.class}) //异常处理器
    public String handleArithException(Exception e){
        log.error("Controller中发生的异常是：{}",e);
        System.out.println(e.toString());
        return "login";//返回视图地址或者ModelAndView
    }

}
